package com.sptpc.speaker;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class WordAdapter extends RecyclerView.Adapter<WordHolder> {

    private List<Word> mWords;
    private Context mContext;

    public WordAdapter(Context activity, List<Word> words) {
        mContext = activity;
        mWords = words;
    }

    @Override
    public WordHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(mContext)
                .inflate(R.layout.list_item, parent, false);
        return new WordHolder(itemView, mContext);
    }

    @Override
    public void onBindViewHolder(final WordHolder holder, final int position) {
        final Word word = mWords.get(position);
        holder.bind(word);
    }

    @Override
    public int getItemCount() {
        return mWords.size();
    }
}
